var sceneReadyBehavior = require('../../behavior-scene/scene-ready');
const app = getApp()

Page({
  behaviors: [sceneReadyBehavior],
  data: {
    modelType:2,
    markerImg: '',
    rotation:'',
    scale:'',
    position:'',
    modelUrl:'',
    musicUrl:'',
    videoUrl:'',
    height: 600,
    heightScale: 1,
    showBackBtn: true,
  },

    /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    const params = app.parsePageParams(options);
    console.log(params)
    if(params.type === 1 || params.type === 4 || params.type === 5){
      this.setData({
        modelType:params.type,
        markerImg: params.arImg,
        rotation:params.rotation,
        scale:params.scale,
        position:params.position,
        modelUrl:params.modelUrl,
        musicUrl:params.audio
      })
    }else{
      this.setData({
        modelType:params.type,
        videoUrl:params.videoUrl,
        markerImg: params.arImg
      })
    }
  },

  handleChangeMarkerImg: function() {
    wx.chooseMedia({
      count: 1,
      sizeType: ['compressed'],
      mediaType: ['image'],
      sourceType: ['album'],
      success: res => {
        const fp = res.tempFiles[0].tempFilePath;
        this.setData({markerImg: fp});
      },
      fail: err => {
        console.error('[xr-demo]chooseImage failed', err);
      }
    });
  },

  onUnload: function () {
    wx.getBackgroundAudioManager().stop();
  },
  // 小程序隐藏时候暂停播放（不加页面将一直播放）
  onHide() {
    wx.getBackgroundAudioManager().stop();
  },
  // testHandle:function(){
  //   wx.navigateTo({
  //     url: '/pages/binding/index',
  //   })
  // }
});